/**
 *
 */
package com.mmlc.network.filter;

import com.androidnetframe.BaseParentActivity;
import com.androidnetframe.httputil.BaseRequestFilterLayer;
import com.androidnetframe.httputil.EntryPageName;
import com.mmlc.meimei.lichengkongjian.been.LogisticstBean;
import com.mmlc.meimei.lichengkongjian.been.SendTraceBean;
import com.mmlc.network.requestbean.SendTraceRequestBean;
import com.mmlc.network.responsebean.SendTraceResponseBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 何强
 *         2015-12-18
 * @修改 张园汀 2015-12-30
 */
public class SendTraceRequestFilter extends BaseRequestFilterLayer {
    public SendTraceRequestBean requestBean = new SendTraceRequestBean();

    public SendTraceRequestFilter(BaseParentActivity context) {
        super(context);
        requestBean.method = "logistics_trace";
        makeRequestParams.entryPageName = EntryPageName.n5_a + "";
        makeRequestParams.setReqeustBean(requestBean, true);
    }


    public List<LogisticstBean> responseBean ;

    public List<SendTraceBean> sendTraceList;
    @Override
    public void getResultSuccess(String responseString, Object obj) {
        parseData((SendTraceResponseBean) obj);
    }

    private void parseData(SendTraceResponseBean resBean) {
        responseBean = new ArrayList<>();

        sendTraceList = new ArrayList<>();

        for(int i=0;i<resBean.getData().size();i++){
            SendTraceResponseBean.DataBean dataBean = resBean.getData().get(i);

            LogisticstBean logisticstBean = new LogisticstBean();

            logisticstBean.orderId = dataBean.getInvoice_no();
            logisticstBean.sourceInfo = dataBean.getShipping_name();

            SendTraceBean sendTraceBean = new SendTraceBean();

            sendTraceBean.infoSource = dataBean.getShipping_name();
            sendTraceBean.sendNumber = dataBean.getInvoice_no();

            for(int j=0;j<dataBean.getGoods_list().size();j++){
                SendTraceResponseBean.DataBean.GoodsListBean g = dataBean.getGoods_list().get(j);
                logisticstBean.putItemBean(g.getImg_thumb_min(),g.getGoods_name(),g.getSpec_name(),g.getPrice(),g.getSend_number());

            }

            responseBean.add(logisticstBean);

            for (int k =0;k<dataBean.getTrace().size();k++){
                SendTraceResponseBean.DataBean.TraceBean traceBean = dataBean.getTrace().get(k);

                sendTraceBean.putItem(traceBean.getDesc(),traceBean.getAdd_time());
            }
            sendTraceList.add(sendTraceBean);
        }
    }
}
